package com.tsd.jxc.utils;

import com.tsd.core.datasource.DataSourceContextHolder;
import com.tsd.core.datasource.SpringContextUtil;
import com.tsd.jxc.setting.service.JxcSettingService;
import com.tsd.jxc.vo.JxcSettingVo;

/**
 * @ClassName: JxcUtils
 * @Description: TODO
 * @Author: Hillpool
 * @Date: 2023/3/30 11:21
 * @Version: 1.0
 */
public class JxcUtils {

    /**
     * 获取进销存系统设置
     *
     * @return
     */
    public static JxcSettingVo getJxcSettingVo() {
        JxcSettingVo settingVo;
        try {
            JxcSettingService jxcSettingService = SpringContextUtil.getBean(JxcSettingService.class);
            settingVo = jxcSettingService.getJxcSettingVo(DataSourceContextHolder.getDataSourceType());
        } catch (Exception e) {
            settingVo = new JxcSettingVo();
        }
        return settingVo;
    }

    /**
     * 判断对账单来源是否出入库单
     *
     * @return
     */
    public static boolean isGenReconciliationByStockBill() {
        JxcSettingVo settingVo = getJxcSettingVo();
        return JxcSettingVo.RECONCILIATION_SOURCE_STOCK_BILL.equals(settingVo.getReconciliation_source());
    }
}
